/*******String函数******/
-- ASCII
SELECT ASCII('A')
FROM DUAL;
-- 65

-- CHR
SELECT CHR('65')
FROM DUAL;
-- A

-- CONCAT
SELECT CONCAT('a', 'bc')
FROM dual;
-- abc

-- DUMP
SELECT DUMP('A')
FROM dual;
-- Typ=96 Len=1: 65

-- INITCAP
SELECT INITCAP('hi there')
FROM dual;
-- Hi There

-- INSTR
SELECT INSTR('This is a playlist', 'is')
FROM dual;
--  3

-- LENGTH
SELECT LENGTH('ABC')
FROM dual;
-- 3

-- LOWER
SELECT LOWER('Abc')
FROM dual;
-- abc

-- LPAD
SELECT LPAD('ABC', 5, '*')
FROM dual;
-- **ABC

-- LTRIM
SELECT LTRIM('ABC')
FROM dual;
-- ABC

-- REGEXP_COUNT
SELECT REGEXP_COUNT('1 2 3 abc', '\d')
FROM dual;
-- 3

-- REGEXP_INSTR
SELECT REGEXP_INSTR('Y2K problem', '\d+')
FROM dual;
-- 2

-- REGEXP_LIKE
SELECT NAME
FROM CUSTOMERS
WHERE REGEXP_LIKE(NAME, 'Ae');
-- Aetna

-- REGEXP_REPLACE
SELECT REGEXP_REPLACE('Year of 2017', '\d+', 'Dragon')
FROM DUAL;
-- Year of Dragon

-- REGEXP_SUBSTR
SELECT REGEXP_SUBSTR('Number 10', '\d+')
FROM DUAL;
-- 10

-- REPLACE
SELECT REPLACE('JACK AND JOND', 'J', 'BL')
FROM dual;
-- BLACK AND BLOND

-- RPAD
SELECT RPAD('ABC', 5, '*')
FROM dual;
-- ABC**

-- RTRIM
SELECT RTRIM(' ABC ')
FROM dual;
--  ABC

-- SOUNDEX
SELECT SOUNDEX('sea')
FROM dual;
-- S000

-- SUBSTR
SELECT SUBSTR('Oracle Substring', 1, 6)
FROM dual;
-- Oracle

-- TRANSLATE
SELECT TRANSLATE('12345', '143', 'bx')
FROM dual;
-- b2x5

-- TRIM
SELECT TRIM(' ABC ')
FROM dual;
-- ABC

-- UPPER
SELECT UPPER('Abc')
FROM dual;
-- ABC

-- DATE
-- ADD_MONTHS
SELECT ADD_MONTHS(DATE '2016-02-29', 1)
FROM DUAL;
-- 2016-03-31

-- CURRENT_DATE
SELECT CURRENT_DATE
FROM dual;
-- 2023-04-28 02:56:54

-- CURRENT_TIMESTAMP
SELECT CURRENT_TIMESTAMP
FROM dual;
-- 2023-04-28 02:57:09.224614 +00:00

-- DBTIMEZONE
SELECT DBTIMEZONE
FROM dual;
-- +00:00

-- EXTRACT
SELECT EXTRACT(YEAR FROM SYSDATE)
FROM dual;
-- 2023

-- FROM_TZ
SELECT FROM_TZ(TIMESTAMP '2017-08-08 08:09:10', '-09:00')
FROM dual;
-- 2017-08-08 08:09:10.000000000 -09:00

-- LAST_DAY
SELECT LAST_DAY(DATE '2016-02-01')
FROM dual;
-- 2016-02-29

-- LOCALTIMESTAMP
SELECT LOCALTIMESTAMP
FROM dual;
-- 2023-04-28 02:57:35.895358

-- MONTHS_BETWEEN
SELECT MONTHS_BETWEEN(DATE '2017-07-01', DATE '2017-01-01')
FROM dual;
-- 6

-- NEW_TIME
SELECT NEW_TIME(TO_DATE('08-07-2017 01:30:45', 'MM-DD-YYYY HH24:MI:SS'), 'AST', 'PST')
FROM dual;
-- 2017-08-06 21:30:45

-- NEXT_DAY
SELECT NEXT_DAY(DATE '2000-01-01', '星期一')
FROM dual;
-- 2000-01-03

-- ROUND
SELECT ROUND(DATE '2017-07-16', 'MM')
FROM dual;
-- 2017-08-01

-- SESSIONTIMEZONE
SELECT SESSIONTIMEZONE
FROM dual;
-- UTC

-- SYSDATE
SELECT SYSDATE
FROM dual;
-- 2023-04-28 10:58:03

-- SYSTIMESTAMP
SELECT SYSTIMESTAMP
FROM dual;
-- 2023-04-28 10:58:13.279596 +08:00

-- TO_CHAR
SELECT TO_CHAR(DATE'2017-01-01', 'DL')
FROM DUAL;
-- 2017年1月1日 星期日

-- TO_DATE
SELECT TO_DATE('2017-01-01', 'YYYY-MM-DD')
FROM dual;
-- 2017-01-01

-- TRUNC
SELECT TRUNC(DATE '2017-07-16', 'MM')
FROM dual;
-- 2017-07-01

-- TZ_OFFSET
SELECT TZ_OFFSET('Europe/London')
FROM dual;
-- +01:00